import http from '@/utils/http'

const BASE_URL = '/system/meetRoom'

export interface MeetingRoomResp {
  id: string
  name: string
  meetingRoomName: string
  officeBuildingId: string
  officeBuildingName: string
  factoryName: string
  floor: string
  capacity: string
  roomCapacity: string
  imageUrl: string
  features: string
  status: string
  createTime: string
  updateTime: string
  createUserString: string
  updateUserString: string
  factoryId: string
}
export interface MeetingRoomDetailResp {
  id: string
  name: string
  officeBuildingId: string
  floor: string
  capacity: string
  imageUrl: string
  features: string
  createTime: string
  updateTime: string
  createUserString: string
  updateUserString: string
  status: number
  disableMode?: string
  customDisableUrl?: string
  doorImgUrl?: string // 门口屏禁用图片URL
}
export interface MeetingRoomQuery {
  name: string | undefined
  // capacity: string | undefined
  sort: Array<string>
}
/**
 * 会议室占用情况线下列表接口
 */
export interface getMeetingRoomListQuery {
  page: string | number
  size: string | number
  meetType?: string | number
  conferenceState?: string | number
  searchDate: string
}

/**
 * 会议室占用情况接口类型
 */
export interface getMeetingRoomDataQuery {
  factoryId: number
  type: string
  date: string
}

export interface MeetingRoomPageQuery extends MeetingRoomQuery, PageQuery { }

/** @desc 查询会议室管理列表 */
export function listMeetingRoom(query: MeetingRoomPageQuery) {
  return http.get<PageRes<MeetingRoomResp[]>>(`${BASE_URL}/getAdminMeetRoomPage`, query)
}

/** @desc 查询会议室管理详情 */
export function getMeetingRoom(id: string) {
  return http.get<MeetingRoomDetailResp>(`${BASE_URL}/getRoom`, { id })
}

/** @desc 新增会议室管理 */
export function addMeetingRoom(data: any) {
  return http.post(`${BASE_URL}/addMeetingRoom`, data)
}

/** @desc 修改会议室管理 */
export function updateMeetingRoom(data: {
  id: number
  name: string
  floor: string
  capacity: number
  imageUrl: string
  roomSort?: number
  status: number
  disableMode?: string
  customDisableUrl?: string
}) {
  return http.post(`${BASE_URL}/v2/updateMeetingRoom`, data)
}

/** @desc 删除会议室管理 */
export function deleteMeetingRoom(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出会议室管理 */
export function exportMeetingRoom(query: MeetingRoomQuery) {
  return http.download(`${BASE_URL}/export`, query)
}

/** @desc 会议室占用情况线下列表接口 */
export function getMeetingRoomList(query: getMeetingRoomListQuery) {
  return http.get(`/system/meet/list?page=${query.page}&size=${query.size}&meetType=${query.meetType}&conferenceState=${query.conferenceState}&searchDate=${query.searchDate}`)
}

/** @desc 获取办公楼 */
export function getSitebuildinglist() {
  return http.get(`/system/factorySite/sitebuildinglist`)
}

/** @desc 获取会议室占用情况 */
export function getMeetingRoomData(data: getMeetingRoomDataQuery) {
  return http.get(`/wecom/usestatusNew?factoryId=${data.factoryId}&type=${data.type}&date=${data.date}`)
}

/** @desc 禁用会议室 */
export function forbidMeetingRoomScreen(params: {
  id: number
  url: string
  status: number
}) {
  return http.get(`${BASE_URL}/forbidScreen`, params)
}
